package com.lightsh.sms;

import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;

public class MonitorService extends Service{
	private MonitorManager mManager;

	@Override
	public void onCreate() {
		super.onCreate();		
		mManager = new MonitorManager(this);
		foreground();
	}

	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		return super.onStartCommand(intent, flags, startId);
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		mManager.onDestroy();
	}

	@Override
	public IBinder onBind(Intent intent) {
		return null;
	}
	
	private void foreground(){
		Notification n = new Notification(android.R.drawable.sym_def_app_icon, getString(R.string.startMonitorSms), System.currentTimeMillis());
		n.icon = android.R.drawable.sym_def_app_icon;
		n.setLatestEventInfo(this, getString(R.string.app_name), getString(R.string.monitorServiceRunning), PendingIntent.getActivity(this, 0, new Intent(), 0));
		n.icon = android.R.drawable.stat_sys_warning;
		n.flags = Notification.FLAG_FOREGROUND_SERVICE;		
		startForeground(R.string.monitorServiceRunning, n);
	}

	public static final void startMonitorService(Context context){
		context.startService(new Intent(context, MonitorService.class));
	}
}
